﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using static Model.AdminInfo;

namespace TakeoutMangesWeb
{
    public partial class AddAdmin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["name"] == null)
                {
                    Response.Redirect("AdminLogin.aspx");

                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Admininfo info = new Admininfo();
            info.AdminUserName = txtName.Text.Trim();
            info.AdminUserPWD = txtPWD.Text.Trim();
            info.Isdelete = 0;
            int r = TakeoutMangesBLL.AdminInfoBLL.InsertAdmin(info);
            if (r > 0)
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功！');location.href='AdminInfo.aspx';</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加失败！')</script>");
                return;
            }
        }
    }
}